# -*- coding: utf-8 -*-
"""
Created on Wed Dec 29 19:06:06 2021

@author: Administrator
"""

import pandas as pd
import numpy as np
import os

path = r'C:\Users\Administrator\Desktop\123'
os.chdir(path)

with open('relations.log') as f:
    content = f.readlines()
    li = [x.split()[1] for x in content if  'ENodeBFunction=1' in x and 'Cdma2000' not in x]
    li1 = [x for x in li if 'EUtranCellRelation' in x]

cellname = [x.split(',')[1].split('=')[1] for x in li1]
plmn = [x.split(',')[3].split('=')[1].split('-')[0] for x in li1]
enb = [x.split(',')[3].split('=')[1].split('-')[1] for x in li1]
cellid = [x.split(',')[3].split('=')[1].split('-')[2] for x in li1]
freq = [x.split(',')[2].split('=')[1] for x in li1]

df = pd.DataFrame({
        'cellname':cellname,
        'plmn':plmn,
        'enb':enb,
        'cellid':cellid,
        'freq':freq,
        })

with pd.ExcelWriter('123.xlsx') as f:
    df.to_excel(f,index  =False)